package com.atguigu.gmall.pay.controller;

import com.alipay.api.AlipayApiException;
import com.atguigu.gmall.pay.service.PayService;
import com.atguigu.gmall.utils.UserAuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/payment")
@RestController
public class PayController {

    @Autowired
    PayService payService;

    //http://api.gmall.com/api/payment/alipay/submit/1607274571539562497
    @GetMapping("/alipay/submit/{orderId}")
    public String aliPay(@PathVariable Long orderId) throws AlipayApiException {

        Long userId = UserAuthUtils.getUserId();
        return payService.generatePayPage(orderId,userId);
    }
}
